//by k1 2022.2.19

params ["_player", "_targetPos", "_type", "_name"];

if (count _targetPos == 0) then [{
	_str = switch _type do {
		case 0: {"kk_Escape_airStrike_1"};
		case 1: {"kk_Escape_airStrike_2"};
		case 2: {"kk_Escape_airStrike_3"};
		case 3: {"kk_Escape_airStrike_4"};
	};
	if (local _player) exitWith {[_player, _str] call BIS_fnc_addCommMenuItem};
	[_player, _str] remoteExec ["Escape_fn_addCommMenuItem", _player];
},{
	/*_smoker = "SmokeShellRed" createVehicle [_targetPos select 0, _targetPos select 1, 10];
	_smoker setVelocity [0,0,-100];
	_smoker setVectorDirandUp [[0,0,-1],[0.1,0.1,1]];*/
	
	_class = switch A3E_VAR_Side_Blufor do {
		case west: {"B_Plane_CAS_01_DynamicLoadout_F"};
		case east: {"O_Plane_CAS_02_dynamicLoadout_F"};
		case resistance: {"I_Plane_Fighter_03_dynamicLoadout_F"};
		default {"B_Plane_CAS_01_DynamicLoadout_F"};
	};
	//_center = createCenter sideLogic; //可以防止被攻击，新版失效
	_grp = createGroup A3E_VAR_Side_Blufor; //_center
	_cas = _grp createUnit ["ModuleCAS_F", _targetPos , [], 0, ""];
	_cas setDir (round random 360);
	_cas setVariable ["vehicle", _class, true];
	_cas setVariable ["type", _type, true]; //0=机炮 1=导弹 2=二者, 3=炸弹

	_Players = call A3E_fnc_GetPlayers - Escape_Players_enemy;
	[ [format ["近空支援: 即将对坐标点%1进行火力覆盖！", mapGridPosition _targetPos], "PLAIN"] ] remoteExec ["TitleText", _Players];
	_str = switch _type do {
		case 0: {"CAS (机炮)"};
		case 1: {"CAS (导弹)"};
		case 2: {"CAS (机炮和导弹)"};
		case 3: {"CAS (炸弹)"};
	};
	[time/60,_targetPos,_str,_name] remoteExec ["Escape_cas_mak", _Players];
}];


